package com.czp.service.impl;

import com.czp.pojo.Article;
import com.czp.repository.ArticleRepository;
import com.czp.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl  implements ArticleService {

    @Autowired
    ArticleRepository articleRepository;



    @Override
    public Page<Article> findAllArticle(int pageNum, int pageSize) {
        Sort sort = Sort.by(Sort.Direction.DESC,"modified");
        PageRequest pageRequest = PageRequest.of(pageNum,pageSize,sort);
        return articleRepository.findAll(pageRequest);
    }
}
